﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HumanResourceWeb.Models
{
    /// <summary>
    /// 社員
    /// </summary>
    public class Employee
    {
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Employee()
        {
        }

        /// <summary>
        /// OID
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 役職
        /// </summary>
        public string Appointment { get; set; }

        /// <summary>
        /// 日報
        /// </summary>
        public List<Journal> Journals { get; set; }

        /// <summary>
        /// 指定した日付の日報一覧を取得
        /// </summary>
        /// <param name="start"></param>
        /// <param name="Terminate"></param>
        /// <returns></returns>
        public IEnumerable<Journal> GetJournal(DateTime start, DateTime terminate)
        {
            // TODO 2010/05/10 yoshioka, inoue DB接続が出来ないのでStubで返す。
            List<Journal> journal = new List<Journal>(){
                new Journal() {
                    Id = 1,
                    StartDate = DateTime.ParseExact("2010/05/10 09:30:00", "yyyy/MM/dd HH:mm:ss", null),
                    TerminateDate = DateTime.ParseExact("2010/05/10 18:00:00", "yyyy/MM/dd HH:mm:ss", null)
                },
                new Journal() {
                    Id = 2,
                    StartDate = DateTime.ParseExact("2010/05/11 09:30:00", "yyyy/MM/dd HH:mm:ss", null),
                    TerminateDate = DateTime.ParseExact("2010/05/11 18:00:00", "yyyy/MM/dd HH:mm:ss", null)
                },
                new Journal() {
                    Id = 3,
                    StartDate = DateTime.ParseExact("2010/05/12 09:30:00", "yyyy/MM/dd HH:mm:ss", null),
                    TerminateDate = DateTime.ParseExact("2010/05/12 18:00:00", "yyyy/MM/dd HH:mm:ss", null)
                },
                new Journal() {
                    Id = 4,
                    StartDate = DateTime.ParseExact("2010/05/17 09:30:00", "yyyy/MM/dd HH:mm:ss", null),
                    TerminateDate = DateTime.ParseExact("2010/05/17 18:00:00", "yyyy/MM/dd HH:mm:ss", null)
                }
            }; 

            return journal.Where(substanse => substanse.StartDate >= start && substanse.TerminateDate <= terminate);
        }
    }
}
